package com.study.juc.threadpool;

import java.lang.ref.Reference;
import java.util.concurrent.TimeUnit;
import java.util.stream.IntStream;

public class ThreadTest {
    public static void main(String[] args) throws InterruptedException {


        SimpleThreadPool simpleThreadPool = new SimpleThreadPool(4, 8, 12, 20);

        IntStream.range(0,30).parallel().forEach(
              i->{
                  simpleThreadPool.execute(()->{
                      try {
                          TimeUnit.SECONDS.sleep(1);
                      } catch (InterruptedException e) {
                          e.printStackTrace();
                      }

                      System.out.println(Thread.currentThread().getName()+" 第"+i+"个任务");
                  });
              }  
        );
        for(;;){
            System.out.println("  activCount:"+simpleThreadPool.getActiveCount());
            TimeUnit.SECONDS.sleep(1);
        }
        
        
    }
}
